'''
# -*- coding:utf-8 -*-
# @Project: DevOps_api
# @Date: 2023/3/16 - 21:11
# @Author: ysg
# @Describe: 

celery.py
'''
import os
from datetime import datetime, timedelta
from celery import Celery

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'DevOps_api.settings.dev')

backend = 'redis://devops_redis:6379/1'
broker = 'redis://devops_redis:6379/0'
app = Celery('devops', broker=broker, backend=backend, include=['celery_task.ops_task'])

# 时区
app.conf.timezone = 'Asia/Shanghai'
# 是否使用 UTC
app.conf.enable_utc = False
# app.conf.beat_schedule = {
#     # 配置多个定时任务
#     'sava_influxdb': {
#         'task': 'celery_task.ops_task.sava_influxdb',
#         'schedule': timedelta(seconds=30),
#         # 'schedule': crontab(hour=8, day_of_week=1),  # 每周一早八点
#         # 'schedule': crontab(hour=9, minute=43),  # 每周一早八点
#     },
#     'get_host': {
#         'task': 'celery_task.ops_task.get_host',
#         'schedule': timedelta(hours=6),
#     },
# }

